﻿Partial Class NorthwindDataSet
    Partial Class ProductsDataTable

        Private Sub ProductsDataTable_ColumnChanging(ByVal sender As Object, ByVal e As System.Data.DataColumnChangeEventArgs) Handles Me.ColumnChanging
            If e.Column.ColumnName = "UnitsInStock" Then
                Dim i As Integer

                If Not (Integer.TryParse(e.ProposedValue.ToString, i)) Then
                    'mporoume me to messagebox i kai me ti setcolumnerror
                    e.Row.SetColumnError(e.Column, "the value is not a number")
                Else
                    If i <= 0 Then
                        e.Row.SetColumnError(e.Column, "the value must not be  negative number")
                    Else
                        e.Row.SetColumnError(e.Column, String.Empty) ' i alliws ""
                    End If
                End If
            End If

        End Sub

        Private Sub ProductsDataTable_RowChanged(ByVal sender As Object, ByVal e As System.Data.DataRowChangeEventArgs) Handles Me.RowChanged
            If (e.Row.Item("UnitsInStock") < 10 And e.Row.Item(UnitsOnOrderColumn) < 100) Then 'duo diaforetikoi tropoi

                e.Row.RowError = "the units on order are very low" '' tha mpei san minima lathous se oli ti grammi
            Else
                e.Row.RowError = ""
            End If
        End Sub

        Private Sub ProductsDataTable_RowChanging(ByVal sender As Object, ByVal e As System.Data.DataRowChangeEventArgs) Handles Me.RowChanging

        End Sub

        Private Sub ProductsDataTable_TableNewRow(ByVal sender As Object, ByVal e As System.Data.DataTableNewRowEventArgs) Handles Me.TableNewRow

            e.Row.Item(UnitPriceColumn) = 0 ' orizoume tin timi kathe kainourgias grammis se 0

        End Sub
    End Class

End Class

Namespace NorthwindDataSetTableAdapters
    
    Partial Public Class ProductsTableAdapter
    End Class
End Namespace
